import { httpGet, httpPost } from '@/http/http'

/**
 * 游戏设置相关接口
 */

// 用户游戏设置数据类型
export interface GameSettings {
  settingId?: number
  userId?: number
  gameCode: string
  gameTime: number
  emojiSpeed: number
  maxEmojis: number
  emojiSizeMin?: number
  emojiSizeMax?: number
  autoPopTime?: number
  createTime?: string
  updateTime?: string
}

/**
 * 获取用户游戏设置
 * @param gameCode 游戏编码
 */
export async function getUserGameSettings(gameCode: string): Promise<GameSettings> {
  const response = await httpGet(`/api/miniapp/game/settings/${gameCode}`)
  return response.data as GameSettings
}

/**
 * 保存用户游戏设置
 * @param gameCode 游戏编码
 * @param settings 游戏设置数据
 */
export async function saveUserGameSettings(gameCode: string, settings: GameSettings): Promise<void> {
  await httpPost(`/api/miniapp/game/settings/${gameCode}`, settings)
}